package estore.web;

import mybatis.dao.Mybatis;
import mybatis.yang.Book;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

@WebServlet(name = "productinfo")
public class ProductinfoServlet extends HttpServlet {
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        Mybatis mybatis=new Mybatis();
        try {
            List<Book> books=mybatis.selectBook();
//            System.out.println(books);
//            System.out.println(books.get(2));
            request.getSession().setAttribute("books",books);
            request.getRequestDispatcher("productInfo.jsp").forward(request,response);

        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
